<template>
  <div class="vip-register">
    <el-form class="vip-register-form" :model="form">
      <el-form-item label="姓名">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="身份证">
        <el-input v-model="form.cardId"></el-input>
      </el-form-item>
      <el-form-item label="电话">
        <el-input v-model="form.phone"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="register">注册</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {registerVip} from "@/api/VipApi";

export default {
  name: "VipRegister",
  data() {
    return {
      form: {
        name: '',
        cardId: '',
        phone: ''
      }
    }
  },
  methods: {
    register() {
      if (this.form.name === '' || this.form.cardId === '' || this.form.phone === '') {
        this.$message.error('请填写信息')
        return
      }
      registerVip(this.form.name, this.form.cardId, this.form.phone).then(res => {
        if (res['code'] === 0){
          this.$message.success('注册成功')
          this.$router.push('/')
        }
      }).catch(e => {
        this.$message.error(e)
      })
    }
  }
}
</script>

<style scoped>

.vip-register-form {
  width: 300px;
  margin: 0 auto;
}
</style>
